//
//  ReportViewController.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/9/1.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "ReportViewController.h"
#import "ReportCell.h"
#import "ReportBottomCell.h"
@interface ReportViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView *tablview;
@end

@implementation ReportViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"举报";
    [self createTablview];
    // Do any additional setup after loading the view.
}
-(void)createTablview{
    self.tablview = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, WIDTH, HEIGHT - 64 - 150) style:UITableViewStylePlain];
    [self.view addSubview:self.tablview];
    self.tablview.scrollEnabled = NO;
    self.tablview.dataSource = self;
    self.tablview.delegate = self;
    [self.tablview registerClass:[ReportCell class] forCellReuseIdentifier:@"ReportCell"];
    [self.tablview registerClass:[ReportBottomCell class] forCellReuseIdentifier:@"ReportBottomCell"];
    UIButton *inforBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [inforBtn setTitle:@"举报须知" forState:UIControlStateNormal];
    [inforBtn setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    [self.view addSubview:inforBtn];
    [inforBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(self.view.mas_bottom).offset(scaleTopAndBottom(-20));
        make.height.mas_equalTo(scaleTopAndBottom(30));
    }];
}
#pragma makr - tablview的代理方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 1) {
        return 1;
    }
    return 5;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        ReportCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReportCell"];
        cell.namelabel.text = @"作品有毒";
        return cell;
    }else{
        ReportBottomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReportBottomCell"];
        cell.namelabel.text = @"其他";
        return cell;
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return scaleTopAndBottom(50);
    }else{
        return scaleTopAndBottom(210);
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return scaleTopAndBottom(50);
    }
    return 0.0f;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 1) {
        return nil;
    }
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor lightGrayColor];
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.text = @"请选择投诉该作品的原因:";
    [view addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view.mas_left).offset(scaleLeftAndRight(15));
        make.centerY.equalTo(view);
        make.right.equalTo(view);
        make.height.mas_equalTo(scaleTopAndBottom(30));
    }];
    return view;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
